package Exercise;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.TextField;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class MainFrame extends JFrame{

	JTextField txt_reult = null;
	TextField txt =null;
	String str_btn1[]= {"Backspace","CE","C"};
	String str_btn3[]= {"7","8","9","/","sqrt","4","5","6","x","%","1","2","3","-","1/x","0","+/-",".","+","="};
	String str_btn2[]= {"MC","MR","MS","M+"};
	public MainFrame(String title,int width,int height,String str_menu[],String str_menuitem[][])
	{
		setTitle(title);
		setSize(width, height);
		Toolkit tool = Toolkit.getDefaultToolkit();
		Dimension dim = tool.getScreenSize();
		int screen_wight = dim.width;
		int screen_height = dim.height;
		setLocation(screen_wight/2-width/2, screen_height/2-height/2);
		JMenuBar bar = MyUitl.createMenu(str_menu, str_menuitem);
		setJMenuBar(bar);
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setVisible(true);
		setLayout(null);
		
		txt_reult = new JTextField();
		txt_reult.setLocation(10, 5);
		txt_reult.setSize(265,25);
		txt_reult.setEditable(false);
		txt_reult.setText("0.");
		txt_reult.setHorizontalAlignment(JTextField.RIGHT);
		txt_reult.setForeground(Color.blue);
		add(txt_reult);
		
		txt = new TextField();
		txt.setLocation(10,40);
		txt.setSize(30, 30);
		txt.setEnabled(false);
		add(txt);
		
		JPanel p = MyUitl.createButtonPanel(str_btn1, 1, 3);
		p.setSize(215, 30);
		p.setLocation(50, 40);
		add(p);
		
		p=MyUitl.createButtonPanel(str_btn2, 4, 1);
		p.setSize(30, 150);
		p.setLocation(10, 80);
		add(p);
		
		p=MyUitl.createButtonPanel(str_btn3, 4, 5);
		p.setSize(225, 150);
		p.setLocation(50, 80);
		add(p);
	}
}
